package pl.edu.agh.gronoMining.frequentSubgraphFinder.frequentSearcher.subgraph.impl;

import java.util.LinkedList;
import java.util.List;

import pl.edu.agh.gronoMining.frequentSubgraphFinder.frequentSearcher.subgraph.DFSCode;
import pl.edu.agh.gronoMining.frequentSubgraphFinder.frequentSearcher.subgraph.StartNodeSubgraph;
import pl.edu.agh.gronoMining.frequentSubgraphFinder.frequentSearcher.subgraph.StartNodeSubgraphList;
import pl.edu.agh.gronoMining.frequentSubgraphFinder.frequentSearcher.subgraph.SubgraphMove;
import pl.edu.agh.gronoMining.frequentSubgraphFinder.graph.GraphException;

public class StartNodeSubgraphListImpl implements StartNodeSubgraphList {

	private List<StartNodeSubgraph> subgraphsList = new LinkedList<StartNodeSubgraph>();
	
	public StartNodeSubgraphListImpl() {
		
	}
	
	public void addStartNodeSubgraph(StartNodeSubgraph startNodeSungraph) {
		subgraphsList.add(startNodeSungraph);
	}
	
	public StartNodeSubgraph getFirstStartNodeSubgraph() {
		return subgraphsList.get(0);
	}
	
	public void remove(StartNodeSubgraph startNodeSungraph) {
		subgraphsList.remove(startNodeSungraph);
	}
	
	public int size() {
		return subgraphsList.size();
	}
	
	public StartNodeSubgraphList performMove(SubgraphMove move) throws GraphException {
		StartNodeSubgraphList result = new StartNodeSubgraphListImpl();
		for (StartNodeSubgraph subgraph : subgraphsList) {
			if (subgraph.performMove(move))
				result.addStartNodeSubgraph(subgraph);
		}
		return result;
	}
	
	public void undoLastMove() throws GraphException {
		for (StartNodeSubgraph subgraph : subgraphsList)
			subgraph.undoLastMove();
	}
	
	public void markLastMoveEdge(boolean isOk) {
		for (StartNodeSubgraph subgraph : subgraphsList)
			subgraph.markLastMoveEdge(isOk);
	}
	
	public void markLastMoveEdge(boolean isOk, DFSCode dfs) {
		for (StartNodeSubgraph subgraph : subgraphsList)
			subgraph.markLastMoveEdge(isOk, dfs);
	}
	
}
